package com.audaque.springboot.foshanupload.core.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;
@Slf4j
@Aspect
@Component
public class ExecutionTimeAspect {

    @Around("execution(* com.audaque.springboot.foshanupload..*(..))") // 替换为你的包名
    public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        Object result = joinPoint.proceed(); // 继续执行过滤链
        stopWatch.stop();
        log.debug("Method " + joinPoint.getSignature() + " executed in " + stopWatch.getTotalTimeMillis() + " ms");
        return result;
    }
}